package com.piesat.quake.business.device.mqtt.param;

import com.piesat.quake.business.device.mqtt.DataType;
import com.piesat.quake.business.device.mqtt.NumberType;

import java.lang.reflect.Field;

import static com.piesat.quake.business.device.mqtt.reader.NumberReader.LITTLE_ENDIAN;

public class LengthParseParam extends NumberParseParam {
    private Integer length=4;

    public LengthParseParam() {
    }

    public LengthParseParam(Integer length) {
        this.length = length;
    }

    public LengthParseParam(Field field, Integer endian) {
        super(field, DataType.NUMBER.ordinal(),endian,NumberType.INT);
    }

    public static LengthParseParam create(Field field) {
        return new LengthParseParam(field,LITTLE_ENDIAN);
    }

    public int getLength() {
        return length;
    }

    public void setLength(Integer length) {
        this.length = length;
    }

    @Override
    public String toString() {
        return "LengthParseParam{" +
                "length=" + length +
                ", field=" + field +
                ", type=" + type +
                '}';
    }
}